package com.liwie.app;
//线程的生命周期【线程的状态】
//线程阻塞的时候会让出CPU时间片【BLOCKED】【WAITING】【TIMED_WAITING】
//Thread.State
//NEW
//RUNNABLE
//BLOCKED
//WAITING
//TIMED_WAITING
//TERMINATED
public class MyApp1 {
    //Thread.State
    public static class MyT1 implements Runnable{
        @Override
        public void run() {
            for (int i = 1; i <= 10; i++) {
                try {
                    Thread.sleep(600);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
    public static class MyT2 implements Runnable{
        @Override
        public void run() {
            for (int i = 201; i <= 210; i++) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }

    public static void main(String[] args) {
        MyT1 myT1 = new MyT1();
        Thread thread=new Thread(myT1,"myt1");
        thread.start();

        MyT2 myT2 = new MyT2();
        Thread thread1 = new Thread(myT2,"myt2");
        thread1.start();
    }
}
